<!DOCTYPE html>
<#assign f = JspTaglibs["http://www.casic304.cn/f"] />
<#assign dicSelect = JspTaglibs["http://www.casic304.cn/dicSelect"]/>
<#assign SourceDept = JspTaglibs["http://www.casic304.cn/SourceDept"]/>
<html>
<head>
    <meta charset="utf-8">
    <title>系统部署方式管理</title>
    <meta name="renderer" content="webkit">
    <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
    <meta name="viewport"
          content="width=device-width, initial-scale=1.0, minimum-scale=1.0, maximum-scale=1.0, user-scalable=0">
    <link rel="stylesheet" href="${ctx}/layui/css/layui.css" media="all"/>
    <link rel="stylesheet" href="${ctx}/qbdmsStatic/iconfont/iconfont.css"/>
    <link rel="stylesheet" href="${ctx}/qbdmsStatic/style/qbdms.css">
    <script type="text/javascript">
        var __ctx = "${ctx}";
    </script>
</head>
<body class="listBody">
<div class="qbdms-list">
    <div class="layui-table-view-body">
        <table id="sysOrgDeployTable" lay-filter="sysOrgDeployTable"></table>
    </div>
</div>
<!-- 列表头部工具栏 -->
<script type="text/html" id="sysOrgDeployHeaderToolsBar">
    <div class="ccpui-enterSel">
        <div class="layui-btn-container">
            <a class="layui-btn layui-btn-sm fillBtn " lay-event="add">
                <span>新增</span>
            </a>
            <a class="layui-btn layui-btn-sm" lay-event="delete">
                <span>删除</span>
            </a>
        </div>
        <form class="layui-form" action="" lay-filter="sysOrgDeployQueryForm">
            <div class="layui-form-body selch">
                <div class="table-top-filter layui-row">
                    <div class="qbdms-listForm">
                        <label class="layui-form-label">组织code</label>
                        <div class="layui-input-block">
                            <input type="text" class="layui-input filter-value" name="Q_orgCode_SL"
                                   placeholder="组织code"/>
                        </div>
                    </div>
                    <div class="qbdms-listForm">
                        <label class="layui-form-label">接口地址</label>
                        <div class="layui-input-block">
                            <input type="text" class="layui-input filter-value" name="Q_ip_SL"
                                   placeholder="IP"/>
                        </div>
                    </div>

                </div>
                <div class="selchBtn">
                    <a class="layui-btn layui-btn-sm fillBtn" lay-event="query">
                        <span>查询</span>
                    </a>
                    <div class="layui-btn-group">
                        <button type="button" class="layui-btn layui-btn-sm" lay-event="clears"
                                style="width: 28px;font-size: 12px;padding: 0">
                            <i class="iconfont  data-iconcommon_refresh"></i>
                        </button>
                        <button type="button" class="layui-btn layui-btn-sm screenParent" lay-event="screen"
                                style="width: 28px;font-size: 12px;padding: 0">
                            <i class="iconfont data-iconcommon_downarrow screen"></i>
                        </button>
                    </div>
                </div>
            </div>
        </form>
    </div>

</script>
<!-- 右侧工具栏 -->
<script type="text/html" id="sysOrgDeployRightToolsBar">
    <a class="RightBtn" lay-event="edit">编辑</a>
    <a class="RightBtn" lay-event="particulars">详情</a>
    <a class="RightBtn layui-btn-xs" lay-event="del">删除</a>
</script>
<script src="${ctx}/qbdmsStatic/public/configFile.js"></script>
<script src="${ctx}/layui/layui.js"></script>
<script>
    //一般直接写在一个js文件中
    layui.config({
        base: serverPath.qbdmsPath + staticPath.qbdmsPath //静态资源所在路径
    }).extend({
        index: 'lib/index' //主入口模块
    }).use(['index', 'table', 'setter', 'form', 'common', 'publicMethods', 'jquery', 'layer'], function () {
        var table = layui.table;
        var setter = layui.setter;
        var form = layui.form;
        var common = layui.common;
        var publicMethods = layui.publicMethods;
        var $ = layui.jquery;
        var layer = layui.layer;
        common.tableSort('sysOrgDeployTable');

        var tableH = publicMethods.tabHeight();



        var cols = [ //初始化的表头， 这里替换成自己的初始化表头json
            {type: 'checkbox', fixed: 'left'}
            , {field: 'sn', type: 'numbers', title: '序号', fixed: 'left', minWidth: '50'}

            ,{field: 'orgCode', title: '单位code'}
            ,{field: 'orgCode', title: '是否上级',templet:function(d){
                    return d.isParent === "0" ? "否" : "是";
                }}
            ,{field: 'depmethod', title: '部署方式'}
            ,{field: 'protocol', title: '协议'}
            ,{field: 'ip', title: '地址',sortname: 'ip'}
            // ,{field: 'port', title: '端口号', sortname: 'port'}
            ,{field: 'remarker', title: '备注', sortname: 'remarker'}

            , {
                fixed: 'right',
                title: '管理',
                toolbar: '#sysOrgDeployRightToolsBar'
            }
        ];

        table.render({
            elem: '#sysOrgDeployTable'
            , height: tableH
            , url: '${ctx}/qbdms/sysOrgDeploy/list'
            , page: publicMethods.pageFun() //开启分页
            , toolbar: '#sysOrgDeployHeaderToolsBar'
            , method: 'post'
            , limit: 20
            , defaultToolbar: ['']
            , autoSort: false //是否排序
            , cols: [cols]
            , done: function () {
                common.tableSelectCon('.ccpui-enterSel .layui-form input', 'a[lay-event=query]', '.ccpui-enterSel');
                table.resize();
            }
        });


        function reflashQuery(isClear) {
            common.tableConditionRender("sysOrgDeployTable", "sysOrgDeployQueryForm", {where: {}}, isClear, false, 20);
            // common.tableConditionRender("wFadongjiTable","wFadongjiQueryForm",{where:{}},isClear,false,20);
        }

        table.on('toolbar(sysOrgDeployTable)', function (obj) {
            var checkStatus = table.checkStatus(obj.config.id);
            var data = checkStatus.data;
            var _this = this;
            switch (obj.event) {
                case 'add':
                    window.location.href = "${ctx}/qbdms/sysOrgDeploy/view/add";
                    break;
                case 'delete':
                    var array = "";
                    for (var i = 0; i < data.length; i++) {
                        array += data[i].id + ",";
                    }
                    delFun(data, array);
                    break;
                case "query":
                    reflashQuery(false);
                    break;
                case "clears":
                    reflashQuery(true);
                    break;
                case "screen":
                    common.initScreenTop('sysOrgDeployTable');
                    form.render();
                    break;
            }
            ;
        });

        table.on('tool(sysOrgDeployTable)', function (obj) {
            var data = obj.data, //获得当前行数据
                layEvent = obj.event; //获得 lay-event 对应的值
            switch (layEvent) {
                case "edit":
                    window.location.href = '${ctx}/qbdms/sysOrgDeploy/view/add?id=' + data.id + "&runId=" + data.runId;
                    break;
                case "particulars":
                    window.location.href = '${ctx}/qbdms/sysOrgDeploy/view/particulars?id=' + data.id;
                    break;
                case "del":
                    delFun(data, data.id);
                    break;
            }
        });

        function delFun(data, id) {
            if (data.length === 0) {
                layer.msg('请先选择一行数据!',{title: false,skin: 'confirm-class'});
            } else {
                layer.confirm(publicMethods.confirmStyle('确定删除当前数据吗?'), {
                    title: false,
                    skin: 'confirm-class'
                }, function (index) {
                    layer.close(index);
                    $.ajax({
                        url: "${ctx}/qbdms/sysOrgDeploy/del",
                        type: "post",
                        data: {id: id},
                        dataType: 'json',
                        success: function (data) {
                            layer.alert(publicMethods.confirmStyle(data.msg), {title: false, skin: 'confirm-class'});
                            //执行重载
                            reflashQuery(true);
                        },
                        error: function (XMLHttpRequest, textStatus, errorThrown) {
                            layer.alert(publicMethods.confirmStyle(data.msg), {title: false, skin: 'confirm-class'});
                            //执行重载
                            reflashQuery(true);
                        }
                    })
                })
            }
        }

        window.Initialization = function () {
            reflashQuery(false);
        };
        /*刷新时间控件*/
        //list页面初始化展开按钮tips展示（展开按钮类名）
        publicMethods.tipsAuto('.screen')
        //筛选条件初始化（页面表格的Id，是否初始化（true、false））
        common.initScreenTop('sysOrgDeployTable', true);
        common.tableSort("sysOrgDeployTable");
    });
</script>
</body>
</html>